<?php
    $parents=M('nav')->where("parentid=0")->order('listorder desc')->select();
    for($i=0;$i<count($parents);$i++){
        $parentid=$parents[$i]['id'];
        $arr=unserialize($parents[$i]['href']);
        $parents[$i]['href']='__ROOT__'.'/'.$arr['action'].'?'.http_build_query($arr['param']);
        $item=M('nav')->where("parentid=$parentid and status=1")->order('listorder asc')->select();
        if(empty($item)){
            $parents[$i]['children']=0;
        }else{
            for($j=0;$j<count($item);$j++){
            if(strpos($item[$j]['href'],"http://") !== 0){
                $arr=unserialize($item[$j]['href']);
                $item[$j]['href']='__ROOT__'.'/'.$arr['action'].'?'.http_build_query($arr['param']);
            }
        }
        $parents[$i]['children']=$item;
        }
    }
?>
<ul class="nav col-md-10">
    <volist name="parents" id="vo">
        <if condition="$vo.children eq 0">
            <li class="qxljt"><a href="{$vo.href}">{$vo.label}</a></li>
            <else />
            <li>
                <a href="{$vo.href}">{$vo.label}</a>
                <dl>
                    <volist name="vo.children" id="child">
                        <dd><a href="{$child.href}">{$child.label}</a></dd>
                    </volist>
                </dl>
            </li>
        </if>
    </volist>
</ul>